home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / tex / cmsnt100.zip / CMSNOTES.BAS next >
BASIC Source File  |  1992-07-23  |  18KB  |  707 lines

  1. ' Process CMS NOTEBOOK files
  2. '
  3. '   Allows reading of each note in file
  4. '   Allows replying to notes, regular mode
  5. '   Allows replying to notes, TEXT mode
  6. '   Allows sending notes
  7. '
  8.   DECLARE SUB AllDone ()
  9.   DECLARE SUB BuildIndex ()
  10.   DECLARE SUB HdrItems ()
  11.   DECLARE SUB HdrNote ()
  12.   DECLARE SUB HelpItems ()
  13.   DECLARE SUB HelpNote ()
  14.   DECLARE SUB Pause ()
  15.   DECLARE SUB ReadIndex ()
  16.   DECLARE SUB ReadNote (note)
  17.   DECLARE SUB SetUp ()
  18.   DECLARE SUB ShowFiles ()
  19.   DECLARE SUB ShowItems ()
  20.   DECLARE SUB ShowNote (note)
  21.   DECLARE SUB Display (file, pointer(), items%, first%, last%)
  22.  
  23.   DECLARE FUNCTION ConvertDate (adate$)
  24.   DECLARE FUNCTION Modtime$ (atime$)
  25.   DECLARE FUNCTION Word$ (aline$, num)
  26.  
  27.   COMMON SHARED dirnote$, dirndx$, indexsize%, notesize%
  28.   COMMON SHARED fsize, title$, version$, dircmd$
  29.   COMMON SHARED pitems(), pnote()
  30.   COMMON SHARED infile$, outfile$, note$(), note, notecount%
  31.  
  32.   title$ = "CMS Notebook processor "
  33.   version$ = "v1r0m0"
  34.  
  35.   PRINT ""
  36.   PRINT ""
  37.   PRINT title$ + version$
  38.  
  39.   SetUp
  40.   ShowFiles
  41.   ShowItems
  42.   AllDone
  43.  
  44.   END
  45.  
  46. '
  47. ' Close the .NOT and .IDX files
  48. '
  49. SUB AllDone
  50.   CLS
  51.   CLOSE #1
  52.   CLOSE #2
  53.   SHELL "del cmsnote.dir"
  54. END SUB
  55.  
  56. '
  57. ' Build an index of the selected .NOT file
  58. '
  59. SUB BuildIndex
  60.  
  61. '        12345678.123 nnnnnnnn  mm-dd-yy  hh:mm  nnnnnnn  nnnnnnn  nnn.nn%
  62.   PRINT "                                                                %";
  63.   LOCATE CSRLIN, 1
  64.   PRINT dirnote$;
  65. '        ....+....1....+....2....+....3....+....4....+....5....+....6....+....7
  66.   LINE INPUT #1, aline$
  67.   notecount% = 0
  68.   notestart = 1
  69.   lines = 0
  70.   OPEN outfile$ FOR OUTPUT AS #2
  71.   WRITE #2, "    0", 0, 0
  72.  
  73.   DO
  74.     lines = lines + 1
  75.  
  76.     IF LEFT$(aline$, 72) = STRING$(72, "=") THEN
  77.        IF notecount% > 0 THEN
  78.           notelines% = notelines% - 1
  79.           size$ = RIGHT$("     " + STR$(notelines%), 5)
  80.           item$ = from$ + " " + ndate$ + " " + size$ + " " + subj$
  81.           FOR z = 1 TO LEN(item$)
  82.               IF MID$(item$, z, 1) = CHR$(34) THEN
  83.                  MID$(item$, z, 1) = "'"
  84.               END IF
  85.           NEXT z
  86.           WRITE #2, item$, notestart, notelines%
  87.        END IF
  88.  
  89.        needhdr$ = "Y"
  90.        notelines% = 0
  91.        notecount% = notecount% + 1
  92.        LOCATE CSRLIN, 41
  93.        PRINT RIGHT$("       " + STR$(notecount%), 7);
  94.        LOCATE CSRLIN, 50
  95.        PRINT RIGHT$("       " + STR$(lines), 7);
  96.        LOCATE CSRLIN, 59
  97.        PRINT USING "###.##%"; (notestart / fsize) * 100;
  98.  
  99.        notestart = SEEK(1)
  100.     ELSE
  101.  
  102.       IF needhdr$ = "Y" THEN
  103.          Work$ = Word$(UCASE$(aline$), 1)
  104.          SELECT CASE Work$
  105.  
  106.             CASE "FROM:"
  107.                from$ = LTRIM$(MID$(aline$, 7))
  108.                from$ = LEFT$(from$ + SPACE$(19), 19)
  109.  
  110.             CASE "DATE:"
  111.                ndate$ = LTRIM$(MID$(aline$, 7))
  112.                ndate$ = LEFT$(ndate$ + SPACE$(14), 14)
  113.  
  114.             CASE "SUBJECT:"
  115.                subj$ = LTRIM$(MID$(aline$, 10))
  116.  
  117.             CASE ""
  118.                needhdr$ = "N"
  119.  
  120.          END SELECT
  121.       END IF
  122.     END IF
  123.     notelines% = notelines% + 1
  124.     LINE INPUT #1, aline$
  125.   LOOP WHILE NOT (EOF(1))
  126.  
  127.   LOCATE CSRLIN, 41
  128.   PRINT RIGHT$("       " + STR$(notecount%), 7);
  129.   LOCATE CSRLIN, 50
  130.   PRINT RIGHT$("       " + STR$(lines), 7);
  131.   LOCATE CSRLIN, 59
  132.   PRINT "100.00%"
  133.  
  134.   notelines% = notelines% - 1
  135.   size$ = RIGHT$("     " + STR$(notelines%), 5)
  136.   item$ = from$ + " " + ndate$ + " " + size$ + " " + subj$
  137.   FOR z = 1 TO LEN(item$)
  138.       IF MID$(item$, z, 1) = CHR$(34) THEN
  139.          MID$(item$, z, 1) = "'"
  140.       END IF
  141.   NEXT z
  142.   WRITE #2, item$, notestart, notelines%
  143.   SEEK #2, 1
  144.   WRITE #2, LEFT$(STR$(notecount%) + SPACE$(5), 5), 0, 0
  145.   CLOSE #2
  146.  
  147. END SUB
  148.  
  149. '
  150. ' To convert a date string of mm/dd/yy into a numeric of yymmdd
  151. '
  152. FUNCTION ConvertDate (adate$)
  153.   adate$ = RIGHT$("0" + adate$, 8)
  154.   am$ = LEFT$(adate$, 2)
  155.   ad$ = MID$(adate$, 4, 2)
  156.   ay$ = RIGHT$(adate$, 2)
  157.   ConvertDate = VAL(ay$ + am$ + ad$)
  158. END FUNCTION
  159.  
  160. '
  161. ' to display either a item or note screen
  162. '
  163. SUB Display (file, pointer(), items%, first%, last%)
  164. '   LOCATE 2, 1
  165. '   PRINT file, pointer(first%), items%, first%, last%
  166.     IF file = 1 THEN
  167.        LOCATE 3, 1
  168.     ELSE
  169.        LOCATE 4, 1
  170.     END IF
  171.     FOR z% = first% TO last%
  172.         IF z% > items% THEN
  173.            EXIT FOR
  174.         END IF
  175.         SEEK file, pointer(z%)
  176.         IF file = 1 THEN
  177.            LINE INPUT #file, line$
  178.            PRINT LEFT$(line$ + SPACE$(80), 80)
  179.         ELSE
  180.            INPUT #file, items$, start, lines%
  181.            PRINT RIGHT$(SPACE$(5) + STR$(z%), 5) + " " + LEFT$(items$ + SPACE$(33), 73)
  182.         END IF
  183.     NEXT z%
  184.     DO WHILE CSRLIN < 24
  185.        PRINT SPACE$(80)
  186.     LOOP
  187.  
  188. END SUB
  189.  
  190. '
  191. ' Print headers for ShowItems
  192. '
  193. SUB HdrItems
  194.     CLS
  195.     PRINT title$ + version$
  196.     LOCATE 1, 40
  197.     PRINT infile$
  198.     LOCATE 1, 67
  199.     PRINT "Items: " + STR$(notecount%)
  200.  
  201.     LOCATE 3, 1
  202.     PRINT "    # From:               Date:          Size: Subject:"
  203. '   PRINT "1234 1234567890123456789 12345678901234 1234 12345678901234567890123456789"
  204.  
  205.     LOCATE 24, 1
  206.     PRINT "Up & Down arrow keys, PgUp & PgDn";
  207.     LOCATE 24, 40
  208.     PRINT "Bottom   Help   Quit   Read   Top";
  209. END SUB
  210.  
  211. '
  212. ' Print headers for ReadNote
  213. '
  214. SUB HdrNote
  215.     CLS
  216.     PRINT title$ + version$
  217.     LOCATE 1, 40
  218.     PRINT "Note: " + STR$(note)
  219.     LOCATE 1, 67
  220.     PRINT "Lines: " + STR$(notesize%)
  221.  
  222.     LOCATE 24, 1
  223.     PRINT "Up & Down arrow keys, PgUp & PgDn";
  224.     LOCATE 24, 40
  225.     PRINT "Bottom   Help   Next   Prev   Quit   Top";
  226. END SUB
  227.  
  228. '
  229. ' Give help for the Items screen
  230. '
  231. SUB HelpItems
  232.   CLS
  233.   PRINT "Help for items screen"
  234.   PRINT ""
  235.   PRINT "Here is where you view the index of notes"
  236.   PRINT ""
  237.   PRINT "You can scroll through the list with the arrow keys and the"
  238.   PRINT "PageUp and PageDown keys"
  239.   PRINT ""
  240.   PRINT "You read a note with the R key and leave this program with Q"
  241.   DO
  242.   LOOP WHILE INKEY$ = ""
  243. END SUB
  244.  
  245. '
  246. ' Give help for the Items screen
  247. '
  248. SUB HelpNote
  249.   CLS
  250.   PRINT "Help for note screen"
  251.   PRINT ""
  252.   PRINT "Here is where you view the note"
  253.   PRINT ""
  254.   PRINT "You can scroll through the note with the arrow keys and the"
  255.   PRINT "PageUp and PageDown keys"
  256.   PRINT ""
  257.   PRINT "You read the next note with the N key, see the previous with P"
  258.   PRINT "and leave this program with Q"
  259.   DO
  260.   LOOP WHILE INKEY$ = ""
  261. END SUB
  262.  
  263. '
  264. ' to take a hh:mmx time and return a 24 hour time as hh:mm
  265. '
  266. FUNCTION Modtime$ (atime$)
  267.     ind$ = RIGHT$(atime$, 1)
  268.     IF ind$ = "P" THEN
  269.        IF LEFT$(atime$, 2) <> "12" THEN
  270.           MID$(atime$, 1, 2) = LTRIM$(STR$(VAL(LEFT$(atime$, 2)) + 12))
  271.        END IF
  272.     END IF
  273.     IF ind$ = "P" OR ind$ = "A" THEN
  274.        atime$ = LEFT$(atime$, LEN(atime$) - 1)
  275.     END IF
  276.     Modtime$ = RIGHT$(atime$, 5)
  277. END FUNCTION
  278.  
  279. '
  280. ' to pause the display
  281. '
  282. SUB Pause
  283.   PRINT ""
  284.   PRINT ""
  285.   PRINT "Press a key to continue"
  286.   DO
  287.   LOOP UNTIL INKEY$ <> ""
  288. END SUB
  289.  
  290. '
  291. ' To read in an existing .NDX file
  292. '
  293. SUB ReadIndex
  294.  
  295. '        12345678.123 nnnnnnnn  mm-dd-yy  hh:mm  nnnnnnn  nnnnnnn  nnn.nn%
  296.   PRINT "                                                                 ";
  297.   LOCATE CSRLIN, 1
  298.   PRINT dirndx$;
  299. '        ....+....1....+....2....+....3....+....4....+....5....+....6....+....7
  300.   OPEN outfile$ FOR INPUT AS #2
  301.   INPUT #2, size$, start, lines
  302.  
  303.   size% = VAL(size$)
  304.  
  305.   DIM pitems(size%)
  306.  
  307.   lines = 0
  308.   FOR z% = 1 TO size%
  309.       pitems(z%) = SEEK(2)
  310.       INPUT #2, items$, start, lines%
  311.  
  312.       lines = lines + lines% + 1
  313.       LOCATE CSRLIN, 41
  314.       PRINT RIGHT$("       " + STR$(z%), 7);
  315.       LOCATE CSRLIN, 50
  316.       PRINT RIGHT$("       " + STR$(lines), 7);
  317.       LOCATE CSRLIN, 59
  318.       PRINT USING "###.##%"; (z% / size%) * 100;
  319.  
  320.       IF EOF(2) THEN
  321.          EXIT FOR
  322.       END IF
  323.  
  324.   NEXT z%
  325.  
  326.   LOCATE CSRLIN, 41
  327.   PRINT RIGHT$("       " + STR$(z%), 7);
  328.   LOCATE CSRLIN, 50
  329.   PRINT RIGHT$("       " + STR$(lines), 7);
  330.   LOCATE CSRLIN, 59
  331.   PRINT "100.00%"
  332.  
  333.   notecount% = z%
  334.   indexsize